from project.views.lib import (
    HTMXProjectSubCreateFormViewNoPK,
    HTMXProjectSubUpdateFormViewNoPK,
    ProjectSubIndexRedirectView,
    ProjectSubAuditDetailViewNoPK,
    ProjectSubFormMixin,
    ProjectSubAuditFormPostAPIViewNoPK,
    template_path,
)

from .. import forms, models


class BeforeImplementIndexView(ProjectSubIndexRedirectView):
    model = models.BeforeImplement
    detail_view_name = "project:before_implement/detail"
    create_view_name = "project:before_implement/create"

class BeforeImplementCreateView(
    ProjectSubFormMixin,
    HTMXProjectSubCreateFormViewNoPK
):
    form_class = forms.BeforeImplementForm
    template_name = template_path("detail_form_base.html")
    create_view_name = "project:before_implement/create"
    detail_view_name = "project:before_implement/detail"

class BeforeImplementDetailView(ProjectSubAuditDetailViewNoPK):
    model = models.BeforeImplement
    form_class = forms.BeforeImplementForm
    template_name = template_path("before_implement/detail.html")
    audit_permission = "user.can_manage_projects"
    audit_viewname = "project:before_implement/audit"


class BeforeImplementUpdateView(HTMXProjectSubUpdateFormViewNoPK):
    model = models.BeforeImplement
    form_class = forms.BeforeImplementForm
    update_view_name = "project:before_implement/update"
    detail_view_name = "project:before_implement/detail"


class BeforeImplementAuditFormPostAPIView(ProjectSubAuditFormPostAPIViewNoPK):
    model = models.BeforeImplement
